package com.web.treatment;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.domain.Employees;
import com.domain.Treatments;
import com.service.TreatmentsService;
import com.util.AuthenticateHttpServlet;
import com.util.PageMaker;

/**
 * Servlet implementation class ProductHandler
 */
@WebServlet("/Treatment/List")
public class TreatmentList extends AuthenticateHttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		TreatmentsService service = new TreatmentsService();
		List<Treatments> list = service.getAllTreatment();
		/*int currentPage = 0;
		if (request.getParameter("page") != null) {
			currentPage = Integer.parseInt(request.getParameter("page"));

			if (request.getParameter("action").equals("next")) {
				currentPage++;
			}
			if (request.getParameter("action").equals("previous")) {
				currentPage--;
			}
		}
		PageMaker<Treatments> maker = new PageMaker<Treatments>(5);
		List<Treatments> output = maker.getCurrentPageList(list, currentPage);
		currentPage = maker.getCurrentPage();
		request.setAttribute("page", currentPage);
		request.setAttribute("treatment", output);*/
		request.setAttribute("tr", list);
		request.getRequestDispatcher("/WEB-INF/jsp/treatmentList.jsp").forward(request, response);
		
	}

}
